home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
-
- global proc refreshIprImage()
- //
- // Description:
- // Update the entire resolution of the iprImage.
- //
- {
- string $iprEngine = "defaultIprEngine";
-
- int $fileSizeInMB = 500;
- int $memoryAvailableInMB = 50;
-
-
- int $resolution[] = `iprEngine -q -resolution $iprEngine`;
- int $width = $resolution[0];
- int $height = $resolution[1];
-
- int $oldRegion[] = `iprEngine -q -region $iprEngine`;
- int $x1_oldRegion = $oldRegion[0];
- int $y1_oldRegion = $oldRegion[1];
- int $x2_oldRegion = $oldRegion[2];
- int $y2_oldRegion = $oldRegion[3];
-
- int $numPixelsInRegion = 0;
- int $regionIsUpToDate = 0;
-
- if ($regionIsUpToDate) {
- $numPixelsInRegion = 100;
- }
-
- int $numPixelsToRender = ($width*$height) - $numPixelsInRegion;
-
- // Compute pixel aspect ratio
- if ($width <= 0) {
- error ("Image of resolution " + $width + " " + $height + " is invalid.");
- return;
- }
- float $pixelAspectRatio = (float) $height / (float) $width;
-
- // Compute the number of tiles
- if ($memoryAvailableInMB <= 0) {
- error ("No memory is available to update the image. Increase the IPR memory limit.");
- return;
-
- }
- float $numberOfTiles = $fileSizeInMB / $memoryAvailableInMB;
-
-
- // Compute the pixels per tile
- if ($numberOfTiles <= 0) {
- warning ("There is nothing to render.");
- return;
- }
- float $pixelsPerTile = $numPixelsToRender / $numberOfTiles;
-
- // Compute the resolution of the tiles
- float $fltXtileSize = sqrt($pixelsPerTile / $pixelAspectRatio);
- float $fltYtileSize = $fltXtileSize * $pixelAspectRatio;
- int $xTileSize = $fltXtileSize;
- int $yTileSize = $fltYtileSize;
-
- print ("Maximum tile size " + $xTileSize + " " + $yTileSize + "\n");
-
-
-
-
-
-
-
-
-
- int $x1 = 0;
- int $y1 = 0;
- int $x2 = $xTileSize;
- int $y2 = $yTileSize;
-
-
- int $done = false;
- int $count = 0;
- int $row = 0;
-
- while (!$done) {
-
- int $new_x1 = $x2;
- int $new_x2 = $x2 + $xTileSize;
-
- int $new_y1 = $row*$yTileSize;
- int $new_y2 = $new_y1 + $yTileSize;
-
- if ($new_y2 > $height)
- $new_y2 = $height;
-
- if ($x2 > $width) {
- $x2 = $width;
- $new_x1 = 0;
- $new_x2 = $xTileSize;
-
- $row++;
- $new_y1 = $row*$yTileSize;
- $new_y2 = $new_y1 + $yTileSize;
-
- if ($new_y2 > $height) {
- $new_y2 = $height;
- }
-
- }
-
-
- iprEngine -e -region $x1 $y1 $x2 $y2 $iprEngine;
-
- int $startTuningProblem = catch(
- `iprEngine -e -startTuning $iprEngine`);
- updateIPRMemoryEstimate();
-
- if (!$startTuningProblem) {
- iprEngine -e -u $iprEngine;
-
- if ($x2 == $width && $y2 == $height) {
- $done = 1;
- }
-
- $x1 = $new_x1;
- $y1 = $new_y1;
- $x2 = $new_x2;
- $y2 = $new_y2;
-
- $count++;
- } else
- break;
- }
-
-
- // Marquee the oldRegion
- iprEngine -e
- -region $x1_oldRegion $y1_oldRegion $x2_oldRegion $y2_oldRegion
- $iprEngine;
-
- int $startedTuning = catch(`iprEngine -e -startTuning $iprEngine`);
- updateIPRMemoryEstimate();
- }
-